home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / ansi / sparc / stdarg.h < prev    next >
C/C++ Source or Header  |  1994-09-14  |  2KB  |  60 lines

  1. /* stdarg.h -    SPARC version */
  2.  
  3. #ifndef _ANSI_SPARC_STDARG_H
  4. #define _ANSI_SPARC_STDARG_H
  5.  
  6. #define _DEFINE_VA_LIST
  7. #include <ansi/sparc/stdtypes.h>
  8.  
  9. /* Indicate that this program uses <stdarg.h>. */
  10. #define __STDARG__
  11.  
  12. #define NEW_VARARGS
  13.  
  14. #define __va_rounded_size(TYPE)  \
  15.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  16.  
  17. #define va_alist  __builtin_va_alist
  18.  
  19. #ifndef va_start
  20. #ifdef NEW_VARARGS
  21. #define va_start(AP, LASTARG) ((AP) = ((char *) __builtin_saveregs()))
  22. #else
  23. #define va_start(AP) \
  24.   (__builtin_saveregs(), (AP) = ((char *) __builtin_next_arg()))
  25. #endif
  26. #endif va_start
  27.  
  28. #ifndef va_end
  29. void va_end (va_list list);        /* Defined in libgcc.a */
  30. #define va_end(pvar)
  31. #endif va_end
  32.  
  33. /* RECORD_TYPE args passed using the C calling convention are
  34.    passed by invisible reference.  ??? RECORD_TYPE args passed
  35.    in the stack are made to be word-aligned; for an aggregate that is
  36.    not word-aligned, we advance the pointer to the first non-reg slot.  */
  37. /* We don't declare the union member `d' to have type TYPE
  38.    because that would lose in C++ if TYPE has a constructor.  */
  39. /* We cast to void * and then to TYPE * because this avoids
  40.    a warning about increasing the alignment requirement.
  41.    The casts to char * avoid warnings about invalid pointer arithmetic.  */
  42. #ifndef va_arg
  43. #define va_arg(pvar,TYPE)                    \
  44. __extension__                            \
  45. ({ TYPE __va_temp;                        \
  46.    ((__builtin_classify_type (__va_temp) >= 12)            \
  47.     ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *),    \
  48.        **(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
  49.     : __va_rounded_size (TYPE) == 8                \
  50.     ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u;    \
  51.      __u.__i[0] = ((int *) (void *) (pvar))[0];        \
  52.      __u.__i[1] = ((int *) (void *) (pvar))[1];        \
  53.      (pvar) = (char *)(pvar) + 8;                \
  54.      *(TYPE *) (void *) __u.__d; })                \
  55.     : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE),    \
  56.        *((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));})
  57. #endif va_arg
  58.  
  59. #endif /* _ANSI_SPARC_STDARG_H */
  60.